﻿using System.Text;
using System.IO;

namespace CSSMixer
{
    public class CssCombiner:CssActionBase
    {
        public bool AddHeader
        {
            get;
            set;
        }

        public string Combine()
        {
            StringBuilder cssBuilder = new StringBuilder();

            foreach (string cssPath in CSSFiles)
            {
                
                if (AddHeader)
                {
                    cssBuilder.Append("/*");
                    cssBuilder.Append('*', 78);
                    cssBuilder.AppendLine();
                    cssBuilder.AppendLine(Path.GetFileName(cssPath));
                    cssBuilder.Append('*', 78);
                    cssBuilder.Append("*/");
                    cssBuilder.AppendLine();
                }
                StreamReader streamReader = new StreamReader(cssPath);
                cssBuilder.AppendLine(streamReader.ReadToEnd());
                streamReader.Close();
            }

            return cssBuilder.ToString();
        }
    }
}
